package com.zerowidth.db.op;

import com.zerowidth.db.DBHelper;
import com.zerowidth.db.bean.CommentBean;
import com.zerowidth.db.utils.StringUtils;
import com.zerowidth.db.utils.TimeUtils;

public class CommentDB {

    public static boolean insert(CommentBean commentBean) {

        if (StringUtils.isEmpty(commentBean.create_time)) {
            commentBean.create_time = TimeUtils.convert(System.currentTimeMillis(), TimeUtils.TIME_FORMAT_YYYY_MM_DD_HH_MM_SS);
        }

        String sql = String.format("INSERT INTO comment(target_id, target_type, action_type, user_id," +
                        " create_time, baby_id, record_day, content) " +
                        " VALUES(%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
                commentBean.target_id, commentBean.target_type, commentBean.action_type, commentBean.user_id,
                commentBean.create_time, commentBean.baby_id, commentBean.day, commentBean.content);

        return DBHelper.executeInsert(sql) > 0;
    }

}
